<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>添加科目</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body {
	font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: center;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 550px;
	height: 400px;
	background: #f8f8f8;
	border: 2px solid #777;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 30px;
	margin-botton: 30px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
<script type="text/javascript">
function checkData(){
	var grade = document.getElementById("grade").value.trim();
	var name = document.getElementById("courseName").value.trim();
	var counts = document.getElementById("counts").value.trim();
	if(grade !="" && name !="" && counts !=""){	
		if(!isNaN(counts) && name !="choose" && grade !="choose"){
			return true;
		}else if(name == "choose"){
			alert("请选择科目名称");
			return false;
		}			
	}else{
		alert("请填写完整！");
		return false;
	}
}
function checkNumber(number){
	if(!isNaN(number)){
		var num = parseint(number);
		if(num < 0){
			alert("章节数是大于0的数字");
			courseForm.counts.focus();
		}else if(num > 12){
			var res = confirm("输入的数字较大，是否修改？");
			if(res == true){
				courseForm.counts.focus();
			}			
		}				
	}else{
		alert("章节数是数字");
	}
	
}
</script>
  </head>
  
  <body>
    <h2>
			添加科目
		</h2>
		<div id="container">
			<form name="courseForm" method="post" action="./servlet/CourseManageServlet?action=add" onsubmit="return checkData()">
				<div class="ele">
					<label>
						年级：
					</label>								
					<select name="grade" id="grade">
					<option value="choose" selected="selected">请选择年级</option>
					<option value="01">初中一年级</option>
					<option value="02">初中二年级</option>
					<option value="03">初中三年级</option>
					<option value="04">高中一年级</option>
					<option value="05">高中二年级</option>
					<option value="06">高中三年级</option>	
					</select>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<label>
						科目名称：
					</label>
					<select name="courseName" id="courseName">
					<option value="choose" selected="selected">请选择科目</option>
					<option value="01">语文</option>
					<option value="02">数学</option>
					<option value="03">英语</option>
					<option value="04">物理</option>
					<option value="05">化学</option>
					<option value="06">生物</option>
					<option value="07">历史</option>
					<option value="08">政治</option>
					<option value="09">地理</option>
					</select>
				</div>
				<div class="ele">
					<label>
						科目描述：
					</label>
					<textarea id="describe1" name="describe1" rows="8" cols="50""></textarea>
				</div>
				<div class="ele">
					<label>
						科目章节总数：
					</label>
					<input type="text" id="counts" onblur="checkNumber(this.value)" name="counts" value="">
				</div>
				<div class="ele">
					<input type="submit" value="提交">
					<input type="reset" value="取消">
				</div>
			</form>
		</div>
		<%
		    if (request.getAttribute("success") != null) {
				String str = (String) request.getAttribute("success");
				if (str.equals("true"))
				    out.write("<script>alert('添加成功！')</script>");
				else
				    out.write("<script>alert('添加失败！')</script>");
		    }
		%>
  </body>
</html>
